package com.kxf.rpc.loadbalance;

import com.kxf.rpc.enumeration.RpcError;
import com.kxf.rpc.exception.RpcException;

import java.net.InetSocketAddress;
import java.util.Set;

/**
 * @author Kxf
 * @create 2021/9/22,0022 16:53
 */
public interface CommonLoadBalance {

    public InetSocketAddress select(Set<String> set);

    static CommonLoadBalance getByCode(int code) {
        switch (code) {
            case 0:
                return new RandomBanlance();
            case 1:
                return new ConsistentHashLoadBalance();
            default:
                throw new RpcException(RpcError.SERIALIZE_NOT_FIND);
        }
    }
}
